﻿// TOCForm.cpp: 实现文件
//

#include "stdafx.h"
#include "zChecker.h"
#include "TOCForm.h"
#include "afxdialogex.h"


// CTOCForm 对话框

IMPLEMENT_DYNAMIC(CTOCForm, CDialog)

CTOCForm::CTOCForm(CWnd* pParent /*=nullptr*/)
	: CDialog(IDD_FORM_TOC, pParent)
{

}

CTOCForm::~CTOCForm()
{
}

void CTOCForm::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
}


BEGIN_MESSAGE_MAP(CTOCForm, CDialog)
	ON_WM_SIZE()
END_MESSAGE_MAP()


// CTOCForm 消息处理程序


BOOL CTOCForm::OnInitDialog()
{
	CDialog::OnInitDialog();

	// TODO:  在此添加额外的初始化
	CWnd* pWndTOC = GetDlgItem(IDC_TOCCONTROL1);
	LPUNKNOWN pUnk = pWndTOC->GetControlUnknown();
	HRESULT hr = pUnk->QueryInterface(IID_ITOCControl2, (LPVOID *)&m_ipTOCControl);
	if (FAILED(hr))
	{
		AfxMessageBox("初始化TOCControl失败");
	}

	return TRUE;  // return TRUE unless you set the focus to a control
				  // 异常: OCX 属性页应返回 FALSE
}


void CTOCForm::OnSize(UINT nType, int cx, int cy)
{
	CDialog::OnSize(nType, cx, cy);

	// TODO: 在此处添加消息处理程序代码
	CWnd* pWndTocCtrl = GetDlgItem(IDC_TOCCONTROL1);
	if (pWndTocCtrl)
	{
		pWndTocCtrl->MoveWindow(0, 0, cx, cy);
	}
}


void CTOCForm::SetBuddyMapControl(IMapControl2Ptr ipMapControl)
{
	m_ipTOCControl->SetBuddyControl(ipMapControl);
}